package net.opentsdb.tsd;

import com.fasterxml.jackson.core.type.TypeReference;
import net.opentsdb.core.IncomingDataPoint;
import org.jboss.netty.handler.codec.http.HttpResponseStatus;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Hujf
 * @title: HttpSerializer
 * @date 2021-09-24 8:54
 * @description: TODO
 */
public abstract class HttpSerializer {

    /** Content type to return with data from this serializer */
    protected String response_content_type = "application/json; charset=UTF-8";

    /** The query used for accessing the DefaultHttpResponse object and other
     * information */
    protected final HttpQuery query;

    public <T extends IncomingDataPoint> List<T> parsePutV1(final Class<T> type,
                                                            final TypeReference<ArrayList<T>> typeReference) {
        throw new BadRequestException(HttpResponseStatus.NOT_IMPLEMENTED,
                "The requested API endpoint has not been implemented",
                this.getClass().getCanonicalName() +
                        " has not implemented parsePutV1");
    }

    public String responseContentType() {
        return this.response_content_type;
    }

    public HttpSerializer(final HttpQuery query) {
        this.query = query;
    }
}
